package projectwork.shchuangge.cn.com.newproject.ui.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;

import projectwork.shchuangge.cn.com.newproject.R;

/**
 * 一个anctivity展示所有的界面
 */
public class ShowActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show);


            //反射强转
            // fragment =ShownFragment.class.newInstance();

        try {

            Class<Fragment>  clazz= (Class<Fragment>) getIntent().getSerializableExtra("class");


            Bundle bundle = getIntent().getBundleExtra("BUNDLE");
            /**
             * 怎么从activity传输数据到fragment
             */

            Fragment fragment = clazz.newInstance();
//            Bundle bundle = new Bundle();
//            bundle.putString("DATA",data);
            fragment.setArguments(bundle);


            getSupportFragmentManager().beginTransaction().replace(R.id.shown_fragment, fragment).commit();


        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }


    }
}
